#ifndef __EVENTFD_H_
#define __EVENTFD_H_

#include <functional>

namespace ln{

using EventCallback = std::function<void()>;

class Eventfd{
public:
    Eventfd(EventCallback &&);
    ~Eventfd();
    void start();
    void wakeup();
    void stop();

private:
    int createEventfd();
    void handleReadEvent();

private:
    int           _eventfd;
    EventCallback _cb;
    bool          _isStarted;
};

}//end of namespace ln

#endif

